<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: ProbabilisticBroadcast Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00180.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-types">Protected Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-static-methods">Static Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="#pro-static-attribs">Static Protected Attributes</a> &#124;
<a href="#pri-methods">Private Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">ProbabilisticBroadcast Class Reference<div class="ingroups"><a class="el" href="a00507.html">netwLayer - network layer modules</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="ProbabilisticBroadcast" --><!-- doxytag: inherits="BaseNetwLayer" -->
<p>This class offers a data dissemination service using probabilistic broadcast. Each packet which arrives from upper layer or from the network is (re-)transmitted n times with n = floor(TTL/bcperiod) with probability beta.  
 <a href="a00180.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00452_source.html">ProbabilisticBroadcast.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for ProbabilisticBroadcast:</div>
<div class="dyncontent">
<div class="center"><img src="a00957.png" border="0" usemap="#ProbabilisticBroadcast_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for ProbabilisticBroadcast:</div>
<div class="dyncontent">
<div class="center"><img src="a00958.png" border="0" usemap="#ProbabilisticBroadcast_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00959.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00214.html">tMsgDesc</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Store messages in a structure so that we can keep some information needed by the protocol.  <a href="a00214.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abf8d4a866267695fc27802ada7862526"></a><!-- doxytag: member="ProbabilisticBroadcast::initialize" ref="abf8d4a866267695fc27802ada7862526" args="(int)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#abf8d4a866267695fc27802ada7862526">initialize</a> (int)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization of the module and some variables. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9435d3ab2ff6a6c68eac011babe7511c"></a><!-- doxytag: member="ProbabilisticBroadcast::finish" ref="a9435d3ab2ff6a6c68eac011babe7511c" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a9435d3ab2ff6a6c68eac011babe7511c">finish</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Called when the simulation has finished. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-types"></a>
Protected Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>messagesTypes</b> { <br/>
&#160;&#160;<b>UNKNOWN</b> = 0, 
<b>BROADCAST_TIMER</b>, 
<b>NEIGHBOR_TIMER</b>, 
<b>BETA_TIMER</b>, 
<br/>
&#160;&#160;<b>DATA</b>
<br/>
 }</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aaa293bbd1aa7cdfbe1498c675d04ec51"></a><!-- doxytag: member="ProbabilisticBroadcast::tMsgDesc" ref="aaa293bbd1aa7cdfbe1498c675d04ec51" args="" -->
typedef struct <br class="typebreak"/>
<a class="el" href="a00214.html">ProbabilisticBroadcast::tMsgDesc</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#aaa293bbd1aa7cdfbe1498c675d04ec51">tMsgDesc</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Store messages in a structure so that we can keep some information needed by the protocol. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7b3c6f1c688d8a7b7254f276d0397263"></a><!-- doxytag: member="ProbabilisticBroadcast::MsgIdSet" ref="a7b3c6f1c688d8a7b7254f276d0397263" args="" -->
typedef std::set&lt; unsigned int &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>MsgIdSet</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afc30da3cce90973f0428acae9b5da46e"></a><!-- doxytag: member="ProbabilisticBroadcast::TimeMsgMap" ref="afc30da3cce90973f0428acae9b5da46e" args="" -->
typedef std::multimap<br class="typebreak"/>
&lt; simtime_t, <a class="el" href="a00214.html">tMsgDesc</a> * &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>TimeMsgMap</b></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7bf4d5846300082695448feb01b9899e"></a><!-- doxytag: member="ProbabilisticBroadcast::handleUpperMsg" ref="a7bf4d5846300082695448feb01b9899e" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a7bf4d5846300082695448feb01b9899e">handleUpperMsg</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle messages from upper layer. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afe7ebec835c0816b263c52a622a655da"></a><!-- doxytag: member="ProbabilisticBroadcast::handleLowerMsg" ref="afe7ebec835c0816b263c52a622a655da" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#afe7ebec835c0816b263c52a622a655da">handleLowerMsg</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle messages from lower layer. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a617c3e0c1a2179b6b560c2286732b2ad"></a><!-- doxytag: member="ProbabilisticBroadcast::handleSelfMsg" ref="a617c3e0c1a2179b6b560c2286732b2ad" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a617c3e0c1a2179b6b560c2286732b2ad">handleSelfMsg</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle self messages. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad145699484af57f4f86319f4c62a9166"></a><!-- doxytag: member="ProbabilisticBroadcast::handleLowerControl" ref="ad145699484af57f4f86319f4c62a9166" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#ad145699484af57f4f86319f4c62a9166">handleLowerControl</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle control messages from lower layer. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac076408bb816780d45ff5b97b851cc6e"></a><!-- doxytag: member="ProbabilisticBroadcast::messageKnown" ref="ac076408bb816780d45ff5b97b851cc6e" args="(unsigned int msgId)" -->
virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#ac076408bb816780d45ff5b97b851cc6e">messageKnown</a> (unsigned int msgId)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks whether a message is known (= kept in memory) or not. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae12c5ea0e8a3f6d2d941bd37181afc13"></a><!-- doxytag: member="ProbabilisticBroadcast::debugMessageKnown" ref="ae12c5ea0e8a3f6d2d941bd37181afc13" args="(unsigned int msgId)" -->
virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#ae12c5ea0e8a3f6d2d941bd37181afc13">debugMessageKnown</a> (unsigned int msgId)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks whether a message is known (= kept in memory) or not. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a4cdd4033716469b5aa654b6a95f243ea">insertMessage</a> (simtime_t_cref bcastDelay, <a class="el" href="a00214.html">tMsgDesc</a> *msgDesc)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Insert a message in both known ID list and message queue. If the message comes in front of the queue (i.e. it will be the next one to be broadcasted, the broadcastTimer is reset accordingly.  <a href="#a4cdd4033716469b5aa654b6a95f243ea"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a738c10077912959af85fe7a322f16dc3"></a><!-- doxytag: member="ProbabilisticBroadcast::popFirstMessageUpdateQueue" ref="a738c10077912959af85fe7a322f16dc3" args="(void)" -->
virtual <a class="el" href="a00214.html">tMsgDesc</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a738c10077912959af85fe7a322f16dc3">popFirstMessageUpdateQueue</a> (void)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the descriptor of the first message in the queue, then remove its pointer from the queue and its id from the known IDs list. Then re-schedule the broadcastTimer to the broadcast instant of the new first element in the list. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3fe5edff45548230ba917138683fd6fa"></a><!-- doxytag: member="ProbabilisticBroadcast::encapsMsg" ref="a3fe5edff45548230ba917138683fd6fa" args="(cPacket *msg)" -->
virtual <a class="el" href="a00028.html#a70ef917f412c70e361b698d6989e677f">netwpkt_ptr_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a3fe5edff45548230ba917138683fd6fa">encapsMsg</a> (cPacket *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a network layer packet which encapsulates the upper layer packet passed to the function. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4a0384a5fb7b18557c33c6b2ead5722d"></a><!-- doxytag: member="ProbabilisticBroadcast::decapsMsg" ref="a4a0384a5fb7b18557c33c6b2ead5722d" args="(netwpkt_ptr_t msg)" -->
virtual cPacket *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a4a0384a5fb7b18557c33c6b2ead5722d">decapsMsg</a> (<a class="el" href="a00028.html#a70ef917f412c70e361b698d6989e677f">netwpkt_ptr_t</a> msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">extracts and returns the application layer packet which is encapsulated in the network layer packet given in argument. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a9a61bf8f39a389f1c3651785fd32149f">insertNewMessage</a> (ProbabilisticBroadcastPkt *pkt, bool iAmInitialSender=false)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Insert a new message in both known ID list and message queue. The message comes either from upper layer or from lower layer. In both cases, it will be inserted in the queue with a broadcast attempt delay taken uniformly between 0 and min(broadcast period, TTL) in order to implement a random backoff for the first broadcast of a message.  <a href="#a9a61bf8f39a389f1c3651785fd32149f"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-static-methods"></a>
Static Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a95cc7ee0bf46971f30699c92711c1734"></a><!-- doxytag: member="ProbabilisticBroadcast::getNextID" ref="a95cc7ee0bf46971f30699c92711c1734" args="()" -->
static long&#160;</td><td class="memItemRight" valign="bottom"><b>getNextID</b> ()</td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3487bf94d9135c4db3a084a20628719d"></a><!-- doxytag: member="ProbabilisticBroadcast::broadcastPeriod" ref="a3487bf94d9135c4db3a084a20628719d" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a3487bf94d9135c4db3a084a20628719d">broadcastPeriod</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Period (in sim time) between two broadcast attempts. Read from omnetpp.ini. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a94d2b55cb729ca2f8b84a97d1932eca2"></a><!-- doxytag: member="ProbabilisticBroadcast::beta" ref="a94d2b55cb729ca2f8b84a97d1932eca2" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a94d2b55cb729ca2f8b84a97d1932eca2">beta</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Probability of each broadcast attempt. Read from omnetpp.ini. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af0d63bc3d6c4b568d040e8f4ae9a3501"></a><!-- doxytag: member="ProbabilisticBroadcast::timeToLive" ref="af0d63bc3d6c4b568d040e8f4ae9a3501" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><b>timeToLive</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5bd284f25c3de84f8d82d84d9da2a33a"></a><!-- doxytag: member="ProbabilisticBroadcast::maxNbBcast" ref="a5bd284f25c3de84f8d82d84d9da2a33a" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a5bd284f25c3de84f8d82d84d9da2a33a">maxNbBcast</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Maximal number of broadcast attempts for each packet. Read from omnetpp.ini. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aee51411ce58e319d4b7be77e946f65bc"></a><!-- doxytag: member="ProbabilisticBroadcast::maxFirstBcastBackoff" ref="aee51411ce58e319d4b7be77e946f65bc" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#aee51411ce58e319d4b7be77e946f65bc">maxFirstBcastBackoff</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Maximal back-off before first broadcast attempt [seconds]. Read from omnetpp.ini. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a142757ae77bf5a9500bbe6a956a4b1a0"></a><!-- doxytag: member="ProbabilisticBroadcast::timeInQueueAfterDeath" ref="a142757ae77bf5a9500bbe6a956a4b1a0" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a142757ae77bf5a9500bbe6a956a4b1a0">timeInQueueAfterDeath</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">How long the message should be kept in queue after its died. That way the message is known if the node receives one of its copy that isn't dead because of TTL de-synchronization due to MAC backoff, propagation delay and clock drift. Read from omnetpp.ini. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac854fd1705c045693986aff67f61b570"></a><!-- doxytag: member="ProbabilisticBroadcast::headerLength" ref="ac854fd1705c045693986aff67f61b570" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#ac854fd1705c045693986aff67f61b570">headerLength</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Length of the NetwPkt header Read from omnetpp.ini. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1a20a131900710634c669a486ef3c113"></a><!-- doxytag: member="ProbabilisticBroadcast::trace" ref="a1a20a131900710634c669a486ef3c113" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>trace</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab71b49b22a10c9a1b5d691a430158d59"></a><!-- doxytag: member="ProbabilisticBroadcast::stats" ref="ab71b49b22a10c9a1b5d691a430158d59" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>stats</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1712864794da337b2963293f4ca402ec"></a><!-- doxytag: member="ProbabilisticBroadcast::debug" ref="a1712864794da337b2963293f4ca402ec" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a1712864794da337b2963293f4ca402ec">debug</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Debug switch for all other modules. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1c12eb05b750dde90df63c358c25f03d"></a><!-- doxytag: member="ProbabilisticBroadcast::broadcastTimer" ref="a1c12eb05b750dde90df63c358c25f03d" args="" -->
cMessage *&#160;</td><td class="memItemRight" valign="bottom"><b>broadcastTimer</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4b9b26b6994df3a5f9a558c453042ad1"></a><!-- doxytag: member="ProbabilisticBroadcast::knownMsgIds" ref="a4b9b26b6994df3a5f9a558c453042ad1" args="" -->
MsgIdSet&#160;</td><td class="memItemRight" valign="bottom"><b>knownMsgIds</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a264b7bb55107fc4c9adff6e5e64d628f"></a><!-- doxytag: member="ProbabilisticBroadcast::msgQueue" ref="a264b7bb55107fc4c9adff6e5e64d628f" args="" -->
TimeMsgMap&#160;</td><td class="memItemRight" valign="bottom"><b>msgQueue</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4a5bf01234efb0e8d8f1ba16eac22eb0"></a><!-- doxytag: member="ProbabilisticBroadcast::debugMsgIdSet" ref="a4a5bf01234efb0e8d8f1ba16eac22eb0" args="" -->
MsgIdSet&#160;</td><td class="memItemRight" valign="bottom"><b>debugMsgIdSet</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a345bf741a515a8d1c540ca1685b385c6"></a><!-- doxytag: member="ProbabilisticBroadcast::nbDataPacketsReceived" ref="a345bf741a515a8d1c540ca1685b385c6" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbDataPacketsReceived</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab9ffe29fa03be20e518fc8036f631eb1"></a><!-- doxytag: member="ProbabilisticBroadcast::nbDataPacketsSent" ref="ab9ffe29fa03be20e518fc8036f631eb1" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbDataPacketsSent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a54a8aa2be349455d0f2cfec50776a2d9"></a><!-- doxytag: member="ProbabilisticBroadcast::nbHops" ref="a54a8aa2be349455d0f2cfec50776a2d9" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbHops</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="abae6a8aa700de8c211d3e4bc9d7a7f7c"></a><!-- doxytag: member="ProbabilisticBroadcast::debugNbMessageKnown" ref="abae6a8aa700de8c211d3e4bc9d7a7f7c" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>debugNbMessageKnown</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a524eae580545f9c4905005dd8a52e31e"></a><!-- doxytag: member="ProbabilisticBroadcast::nbDataPacketsForwarded" ref="a524eae580545f9c4905005dd8a52e31e" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbDataPacketsForwarded</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aca59561a35147404a3d66cd5ba57ec58"></a><!-- doxytag: member="ProbabilisticBroadcast::oneHopLatencies" ref="aca59561a35147404a3d66cd5ba57ec58" args="" -->
cOutVector&#160;</td><td class="memItemRight" valign="bottom"><b>oneHopLatencies</b></td></tr>
<tr><td colspan="2"><h2><a name="pro-static-attribs"></a>
Static Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aca74a9f2aa59ab504d35733a720409da"></a><!-- doxytag: member="ProbabilisticBroadcast::id_counter" ref="aca74a9f2aa59ab504d35733a720409da" args="" -->
static long&#160;</td><td class="memItemRight" valign="bottom"><b>id_counter</b> = 0</td></tr>
<tr><td colspan="2"><h2><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a964879f6e15313ffe6a1486eff965b21"></a><!-- doxytag: member="ProbabilisticBroadcast::ProbabilisticBroadcast" ref="a964879f6e15313ffe6a1486eff965b21" args="(const ProbabilisticBroadcast &amp;)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a964879f6e15313ffe6a1486eff965b21">ProbabilisticBroadcast</a> (const <a class="el" href="a00180.html">ProbabilisticBroadcast</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor is not allowed. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5294643076bf92f407fd618c63c79666"></a><!-- doxytag: member="ProbabilisticBroadcast::operator=" ref="a5294643076bf92f407fd618c63c79666" args="(const ProbabilisticBroadcast &amp;)" -->
<a class="el" href="a00180.html">ProbabilisticBroadcast</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00180.html#a5294643076bf92f407fd618c63c79666">operator=</a> (const <a class="el" href="a00180.html">ProbabilisticBroadcast</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Assignment operator is not allowed. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>This class offers a data dissemination service using probabilistic broadcast. Each packet which arrives from upper layer or from the network is (re-)transmitted n times with n = floor(TTL/bcperiod) with probability beta. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Damien Piguet </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a4cdd4033716469b5aa654b6a95f243ea"></a><!-- doxytag: member="ProbabilisticBroadcast::insertMessage" ref="a4cdd4033716469b5aa654b6a95f243ea" args="(simtime_t_cref bcastDelay, tMsgDesc *msgDesc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ProbabilisticBroadcast::insertMessage </td>
          <td>(</td>
          <td class="paramtype">simtime_t_cref&#160;</td>
          <td class="paramname"><em>bcastDelay</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00214.html">tMsgDesc</a> *&#160;</td>
          <td class="paramname"><em>msgDesc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Insert a message in both known ID list and message queue. If the message comes in front of the queue (i.e. it will be the next one to be broadcasted, the broadcastTimer is reset accordingly. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">bcastDelay</td><td>relative (to now) simulator time of next broadcast attempt. </td></tr>
    <tr><td class="paramname">msg</td><td>descriptor of the message to insert in the queue. </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="a00028.html#a7df0d33fcf757b2e63af619f28bf3312">BaseNetwLayer::myNetwAddr</a>.</p>

<p>Referenced by <a class="el" href="a00180.html#a617c3e0c1a2179b6b560c2286732b2ad">handleSelfMsg()</a>, and <a class="el" href="a00180.html#a9a61bf8f39a389f1c3651785fd32149f">insertNewMessage()</a>.</p>
<div class="fragment"><pre class="fragment">{
  TimeMsgMap::iterator pos;
  simtime_t bcastTime = simTime() + bcastDelay;

  EV &lt;&lt; <span class="stringliteral">&quot;PBr: &quot;</span> &lt;&lt; simTime() &lt;&lt; <span class="stringliteral">&quot; n&quot;</span>  &lt;&lt; <a class="code" href="a00028.html#a7df0d33fcf757b2e63af619f28bf3312" title="cached variable of my networ address">myNetwAddr</a> &lt;&lt; <span class="stringliteral">&quot;         insertMessage() bcastDelay = &quot;</span> &lt;&lt; bcastDelay &lt;&lt; <span class="stringliteral">&quot; Msg ID = &quot;</span> &lt;&lt; msgDesc-&gt;pkt-&gt;getId() &lt;&lt; endl;
  <span class="comment">// update TTL field of the message to the value it will have when taken out of the list</span>
  msgDesc-&gt;pkt-&gt;setAppTtl(msgDesc-&gt;pkt-&gt;getAppTtl() - bcastDelay);
  <span class="comment">// insert message ID in ID list.</span>
  knownMsgIds.insert(msgDesc-&gt;pkt-&gt;getId());
  <span class="comment">// insert key value pair &lt;broadcast time, pointer to message&gt; in message queue.</span>
  pos = msgQueue.insert(make_pair(bcastTime, msgDesc));
  <span class="comment">// if the message has been inserted in the front of the list, it means that it</span>
  <span class="comment">// will be the next message to be broadcasted, therefore we have to re-schedule</span>
  <span class="comment">// the broadcast timer to the message&#39;s broadcast instant.</span>
  <span class="keywordflow">if</span> (pos == msgQueue.begin()) {
    EV &lt;&lt; <span class="stringliteral">&quot;PBr: &quot;</span> &lt;&lt; simTime() &lt;&lt; <span class="stringliteral">&quot; n&quot;</span>  &lt;&lt; <a class="code" href="a00028.html#a7df0d33fcf757b2e63af619f28bf3312" title="cached variable of my networ address">myNetwAddr</a> &lt;&lt; <span class="stringliteral">&quot;         message inserted in the front, reschedule it.&quot;</span> &lt;&lt; endl;
    cancelEvent(broadcastTimer);
    scheduleAt(bcastTime, broadcastTimer);
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="a9a61bf8f39a389f1c3651785fd32149f"></a><!-- doxytag: member="ProbabilisticBroadcast::insertNewMessage" ref="a9a61bf8f39a389f1c3651785fd32149f" args="(ProbabilisticBroadcastPkt *pkt, bool iAmInitialSender=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ProbabilisticBroadcast::insertNewMessage </td>
          <td>(</td>
          <td class="paramtype">ProbabilisticBroadcastPkt *&#160;</td>
          <td class="paramname"><em>pkt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>iAmInitialSender</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Insert a new message in both known ID list and message queue. The message comes either from upper layer or from lower layer. In both cases, it will be inserted in the queue with a broadcast attempt delay taken uniformly between 0 and min(broadcast period, TTL) in order to implement a random backoff for the first broadcast of a message. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">msgDesc</td><td>descriptor of the message to insert in the queue. </td></tr>
    <tr><td class="paramname">iAmInitialSender</td><td>message comes from upper layer, I am its creator and initial sender. </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="a00180.html#a3487bf94d9135c4db3a084a20628719d">broadcastPeriod</a>, <a class="el" href="a00180.html#a4cdd4033716469b5aa654b6a95f243ea">insertMessage()</a>, <a class="el" href="a00180.html#aee51411ce58e319d4b7be77e946f65bc">maxFirstBcastBackoff</a>, and <a class="el" href="a00028.html#a7df0d33fcf757b2e63af619f28bf3312">BaseNetwLayer::myNetwAddr</a>.</p>

<p>Referenced by <a class="el" href="a00180.html#afe7ebec835c0816b263c52a622a655da">handleLowerMsg()</a>, and <a class="el" href="a00180.html#a7bf4d5846300082695448feb01b9899e">handleUpperMsg()</a>.</p>
<div class="fragment"><pre class="fragment">{
  simtime_t ttl = pkt-&gt;getAppTtl();

  <span class="keywordflow">if</span> (ttl &gt; 0) {
    simtime_t bcastDelay;
    <a class="code" href="a00180.html#aaa293bbd1aa7cdfbe1498c675d04ec51" title="Store messages in a structure so that we can keep some information needed by the protocol.">tMsgDesc</a>* msgDesc;

    <span class="comment">// insert packet in queue with delay in [0, min(TTL, broadcast period)].</span>
    <span class="comment">// since the insertion schedules the message for its first broadcast attempt,</span>
    <span class="comment">// we use a uniform random back-off taken between now and the broadcast delay</span>
    <span class="comment">// to avoid having all nodes in the neighborhood forward the packet at the same</span>
    <span class="comment">// time. Backoffs used at MAC layer are thought to be too short.</span>
    <span class="keywordflow">if</span> (<a class="code" href="a00180.html#a3487bf94d9135c4db3a084a20628719d" title="Period (in sim time) between two broadcast attempts. Read from omnetpp.ini.">broadcastPeriod</a> &lt; <a class="code" href="a00180.html#aee51411ce58e319d4b7be77e946f65bc" title="Maximal back-off before first broadcast attempt [seconds]. Read from omnetpp.ini.">maxFirstBcastBackoff</a>)
      bcastDelay = <a class="code" href="a00180.html#a3487bf94d9135c4db3a084a20628719d" title="Period (in sim time) between two broadcast attempts. Read from omnetpp.ini.">broadcastPeriod</a>;
    <span class="keywordflow">else</span>
      bcastDelay = <a class="code" href="a00180.html#aee51411ce58e319d4b7be77e946f65bc" title="Maximal back-off before first broadcast attempt [seconds]. Read from omnetpp.ini.">maxFirstBcastBackoff</a>;
    <span class="keywordflow">if</span> (bcastDelay &gt; ttl)
      bcastDelay = ttl;
    EV &lt;&lt; <span class="stringliteral">&quot;PBr: &quot;</span> &lt;&lt; simTime() &lt;&lt; <span class="stringliteral">&quot; n&quot;</span>  &lt;&lt; <a class="code" href="a00028.html#a7df0d33fcf757b2e63af619f28bf3312" title="cached variable of my networ address">myNetwAddr</a> &lt;&lt; <span class="stringliteral">&quot; insertNewMessage(): insert packet &quot;</span> &lt;&lt; pkt-&gt;getId() &lt;&lt; <span class="stringliteral">&quot; with delay &quot;</span>
       &lt;&lt; bcastDelay &lt;&lt; endl;
    <span class="comment">// create container for message and initialize container&#39;s values.</span>
    msgDesc = <span class="keyword">new</span> <a class="code" href="a00180.html#aaa293bbd1aa7cdfbe1498c675d04ec51" title="Store messages in a structure so that we can keep some information needed by the protocol.">tMsgDesc</a>;
    msgDesc-&gt;pkt = pkt;
    msgDesc-&gt;nbBcast = 0;  <span class="comment">// so far, pkt has been forwarded zero times.</span>
    msgDesc-&gt;initialSend = iAmInitialSender;
    debugMsgIdSet.insert(pkt-&gt;getId());
    <a class="code" href="a00180.html#a4cdd4033716469b5aa654b6a95f243ea" title="Insert a message in both known ID list and message queue. If the message comes in front of the queue ...">insertMessage</a>(uniform(0, bcastDelay), msgDesc);
  }
  <span class="keywordflow">else</span> {
    EV &lt;&lt; <span class="stringliteral">&quot;PBr: &quot;</span> &lt;&lt; simTime() &lt;&lt; <span class="stringliteral">&quot; n&quot;</span>  &lt;&lt; <a class="code" href="a00028.html#a7df0d33fcf757b2e63af619f28bf3312" title="cached variable of my networ address">myNetwAddr</a> &lt;&lt; <span class="stringliteral">&quot; insertNewMessage(): got new packet with TTL = 0.&quot;</span> &lt;&lt; endl;
    <span class="keyword">delete</span> pkt;
  }
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/netw/<a class="el" href="a00452_source.html">ProbabilisticBroadcast.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/netw/ProbabilisticBroadcast.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00180.html">ProbabilisticBroadcast</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:33 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
